<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8">
    <title>Sucha's Blog - Archive for August, 2013</title>
    <meta name="generator" content="MarkdownProjectCompositor.lua">
    <meta name="author" content="Sucha">
    <meta name="keywords" content="suchang, programming, Linux, Lua">
    <meta name="description" content="Sucha's blog">
    <link rel="shortcut icon" href="../images/ico.png">
    <link rel="stylesheet" type="text/css" href="../styles/blog.css">
    <link rel="stylesheet" type="text/css" href="../styles/prism.min.css">
    <style id="site_theme"></style>
  </head>
  <body>
    <div id="body">
      <div id="text">
	   <!-- Page published by cmark-gfm begins here --><h1>Sucha's Blog ~ Archive for August, 2013</h1>
<p><a id="p2"></a></p>
<div class="date">13年8月27日 周二 23:47</div>
<h2>TexturePacker 图片打包工具</h2>
<p>最近在做 2D 游戏开发，用到了图片打包工具，网上搜到的教程好多都是
TexturePacker 的，于是就到官网下载试用了一下，因为只用到打包的功能，感觉
还是很简单的。</p>
<p>下载后可以试用一周 pro 版的功能，免费版的功能目前不晓得是否足够支持开发。</p>
<p>后来看到有童鞋联系开发者拿到了 pro 版的 Licese key，我上官网一查，好东西，
说有自己博客并满足一定条件的就可以申请，然后写一片简短的博客做为回报便好。</p>
<p>二话不说，就把自己的博客地址填上去了，然后作者还回信了，德国人真慷慨，给
了 key 不说，还附送了一枚 PhysicsEditor 的 key，真谢谢他了，虽然暂时还用
不到。</p>
<p>于是就有了这篇 blog，in return。</p>
<p>作者还说如果写教程的话可以在网站的教程页面弄个链接，当时我还跃跃欲试的，
可后来发现这个软件虽然支持格式丰富，但貌似没有很复杂的功能，教程还真的很
难写呢。</p>
<p>以后要是用到高级功能，有心得的话再出教程吧。</p>
<p>提供链接 <a href="http://www.codeandweb.com/texturepacker">http://www.codeandweb.com/texturepacker</a></p>
<div class="category"><a href="CategoryProgramming.html">CategoryProgramming</a> / <a href="2013-08.html#p2">Permalink</a> / <a href="https://github.com/lalawue/homepage/discussions/categories/blog" target="_blank">Discussion</a></div>
<!-- date: 2013-08-27T23:47:42+0800 -->
<p><a id="p1"></a></p>
<div class="date">13年8月12日 周一 14:26</div>
<h2>在C/C++/Objc中快速定位当前文件内的函数</h2>
<p>同样是在昨天的那个帖子里面，列出了一些小函数，可以在 Xcode 的 Objc 文件里
面快速跳转到函数、页面定义的成员、&quot;#pragma mark -&quot; Xcode 标签，非常方便
快捷。</p>
<p>我就想着将其适配到 C/C++ 中，因为实在是太方便了，要比使用 speedbar 来定
位跳转简单快捷得多。</p>
<p>由于是使用正则表达式来处理上下文无关的文法，因此严格来说，不管是而在
C/C++/Objc 中，这些匹配用的正则表达式是不完全的，还是可能会错漏的，不过对
于大部分的情况，应该是够用了。</p>
<pre><code class="language-lisp">;; for Xcode pragma mark, and C/C++ functions
(require 'anything)
(require 'anything-config)

(defvar anything-c-source-objc-headline
  '((name . &quot;Objective-C Headline&quot;)
    (headline  &quot;^[-+@]\\|^#pragma mark&quot;)
))

(defvar anything-c-source-c-headline
  '((name . &quot;C Headline&quot;)
    (headline  &quot;^[A-Za-z_]+?[ A-Za-z_0-9\*]+[A-Za-z_0-9]+?(&quot;)
))

(defvar anything-c-source-cpp-headline
  '((name . &quot;Cpp Headline&quot;)
    (headline  &quot;^[A-Za-z_]+?[ A-Za-z_:~0-9\*]+[A-Za-z_0-9]+?(&quot;)
))

(defun c-base-mode-headline ()
  (interactive)
  ;; Set to 500 so it is displayed even if all methods are not narrowed down.
  (let ((anything-candidate-number-limit 500))
    (cond
     ((eq major-mode 'objc-mode) 
      (anything-other-buffer '(anything-c-source-objc-headline)
                             &quot;*ObjC Headline*&quot;))
     ((eq major-mode 'c++-mode)
      (anything-other-buffer '(anything-c-source-cpp-headline)
                             &quot;*Cpp Headline*&quot;))
     ((eq major-mode 'c-mode)
      (anything-other-buffer '(anything-c-source-c-headline)
                             &quot;*C Headline*&quot;))
     )))

(add-hook
 'c-mode-common-hook
 (lambda ()
   (define-key c-mode-base-map (kbd &quot;M-i&quot;) 'c-base-mode-headline)
))
</code></pre>
<div class="category"><a href="CategoryProgramming.html">CategoryProgramming</a> / <a href="2013-08.html#p1">Permalink</a> / <a href="https://github.com/lalawue/homepage/discussions/categories/blog" target="_blank">Discussion</a></div>
<!-- date: 2013-08-12T14:26:25+0800 -->
<p><a id="p0"></a></p>
<div class="date">13年8月11日 周日 21:44</div>
<h2>在头文件与源代码之间快速跳转</h2>
<p>今天忙着建立 Emacs 编写 objc 代码的环境，根据这个帖子
<a href="http://roupam.github.io/blog/2012/10/07/emacs-for-xcode+ios-development/">Setup Emacs for XCode+iOS development</a>，里面有说到一个快速跳转 objc 源文件与头
文件的小函数。</p>
<p>我稍微改了一下，可以适应于 C/C++/Objc 的代码，当然，可以再根据需要添加诸
如 Java 语言的支持，反正改起来超简单。</p>
<pre><code class="language-lisp">;; jump between source and header file
(defun c-base-mode-in-header-file ()
  (let* ((filename (buffer-file-name))
         (extension (car (last (split-string filename &quot;\\.&quot;)))))
    (string= &quot;h&quot; extension)))

(defun c-base-mode-file-jump-to-extension (extension)
  (let* ((filename (buffer-file-name))
         (file-components (append (butlast (split-string filename
                                                         &quot;\\.&quot;))
                                  (list extension)))
         (filepath (mapconcat 'identity file-components &quot;.&quot;)))
    (if (file-readable-p filepath)
        (find-file filepath)
      nil)))


;;; Assumes that Header and Source file are in same directory
(defun c-base-mode-jump-between-header-source ()
  (interactive)
  (if (c-base-mode-in-header-file)
      (or
       (c-base-mode-file-jump-to-extension &quot;m&quot;)
       (c-base-mode-file-jump-to-extension &quot;mm&quot;)
       (c-base-mode-file-jump-to-extension &quot;c&quot;)
       (c-base-mode-file-jump-to-extension &quot;cc&quot;)
       (c-base-mode-file-jump-to-extension &quot;cpp&quot;))
    (c-base-mode-file-jump-to-extension &quot;h&quot;)))


(add-hook
 'c-mode-common-hook
 (lambda ()
   (define-key c-mode-base-map (kbd &quot;C-c t&quot;)
 'c-base-mode-jump-between-header-source)
))
</code></pre>
<div class="category"><a href="CategoryProgramming.html">CategoryProgramming</a> / <a href="2013-08.html#p0">Permalink</a> / <a href="https://github.com/lalawue/homepage/discussions/categories/blog" target="_blank">Discussion</a></div>
<!-- date: 2013-08-11T21:44:07+0800 -->
<!-- Page published by cmark-gfm ends here -->
  <div id="foot">2004-<script>var d = new
	Date();document.write(d.getFullYear())</script> &copy;
	Sucha. Powered by MarkdownProjectCompositor.
  </div>
  </div><!-- text -->
  <div id="sidebar">
  </div><!-- sidebar -->
  <script src="../js/prism.min.js" async="async"></script>
  <script src="../js/blog_sidebar.js"></script>
  </div> <!-- body -->
</body>
</html>